package com.bnz.test;

import com.bnz.pojo.PageResult;
import com.bnz.pojo.Student;
import com.bnz.pojo.StudentVo;
import com.bnz.service.IStudentService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.web.bind.annotation.RestController;
import sun.reflect.generics.tree.VoidDescriptor;

import java.util.List;

@RestController
@SpringBootTest
public class testSM01 {
    @Autowired
    private IStudentService studentService;
//    查询所有
    @Test
    public void findAll(){
        System.out.println("_______________________");
        System.out.println(studentService.list());
    }
    //怎加
    @Test
    public void inster(){
        Student student = new Student("往往风","男",22,"天南",2);
        studentService.save(student);
    }
    //单个查询
    @Test
    public void byId(){
        String a = "1582937091417952258";
        System.out.println(studentService.getById(a));
    }
    //修改
    @Test
    public void update(){
        String a = "1582937091417952258";
        Student student =studentService.getById(a);
        student.setSname("小溪");
        studentService.updateById(student);
    }
    //条件查询
    @Test
    public void ByName(){
        StudentVo  vo =new StudentVo();
        vo.setSname("小");
       List<Student> s  =  studentService.findWoder(vo);
        System.out.println("s = " + s);
    }
    //分页查找
    @Test
    public void findByP(){
        int page =1;
        int pageSize =3;
       PageResult<Student> pageResult = studentService.findByP(page,pageSize);
        System.out.println("pageResult = " + pageResult);
    }
    //分页带条件
    @Test
    public void findPageByName(){
        int page =1;
        int pageSize =3;
        StudentVo vo = new StudentVo();
        vo.setSname("火");
        PageResult<Student> pageResult = studentService.findPageByName(page,pageSize,vo);
        System.out.println("pageResult = " + pageResult);
    }
    //删除
    @Test
    public void deleted(){
        String a ="13";
        studentService.deleted(a);
    }
}
